import logging

from repoze_who.lib.base import *

log = logging.getLogger(__name__)

class HomeController(BaseController):

    def index(self):
        # Return a rendered template
        #   return render('/some/template.mako')
        # or, Return a response
        return render('/home/index.mako')

    def private(self):
        identity = request.environ.get('repoze.who.identity')
        if identity is None:
            abort(401)
        user = identity.get('user')
        return render('/home/private.mako')

    def logout(self, environ):
        path_info = environ['PATH_INFO']
        if path_info.endswith(g.SIGNOUT_PART):
            h.redirect_to(path_info[:0-len(g.SIGNOUT_PART)])
        else:
            h.redirect_to("/")
